import request from '@/utils/request'

export function getSalesReport(query) {
  let url = '/api/report/order-statement'
  return request({
    url: url,
    method: 'get',
    params: query
  })
}

export function getSendReceiveReport(query) {
  let url = '/api/report/warehouse-log'
  return request({
    url: url,
    method: 'get',
    params: query
  })
}

export function getPerformanceStatement(query) {
  let url = '/api/performance-statement'
  return request({
    url: url,
    method: 'get',
    params: query
  })
}

export function getProductSaleDetail(query) {
  const q = {
    page: query.page,
    limit: query.limit
  }
  if (query.category && query.category !== '') {
    q.category_id = query.category
  }
  if (query.sub_category && query.sub_category !== '') {
    q.category_id = query.sub_category
  }
  if (query.keyword && query.keyword !== '') {
    q.keyword = query.keyword
  }

  if (query.from_date && query.from_date !== '') {
    q.from_date = query.from_date
  }

  if (query.to_date && query.to_date !== '') {
    q.to_date = query.to_date
  }

  return request({
    url: '/api/report/product-sale-detail',
    method: 'get',
    params: q
  })
}

export function getInventoryBalanceSheet() {
  let url = '/api/report/inventory-balance-sheet'
  return request({
    url: url,
    method: 'get'
  })
}
